package com.yunhe.assist.controller;

import com.alibaba.fastjson.JSONObject;
import com.yunhe.assist.domain.ParkIntroduce;
import com.yunhe.assist.model.ParkIntroduceSubmitVO;
import com.yunhe.assist.service.ParkIntroduceService;
import com.yunhe.common.model.ResultObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 园区介绍
 */
@Api(value = "ParkIntroduce", description = "park_introduce维护", tags = {"Model_ParkIntroduce"})
@RestController
@RequestMapping(value = "/parkIntroduce")
public class ParkIntroduceController {

    @Autowired
    private ParkIntroduceService parkIntroduceService;

    @ApiOperation(value = "新增park_introduce",notes = "parkIntroduce：封装对象，其中园区id，园区名称，介绍内容必填，其他不传。" +
            "contacts:对象集合，contactPerson联系人，contactPhone联系方式")
    @PostMapping("/createParkIntroduce")
    public ResponseEntity<ResultObject> createParkIntroduce(@RequestBody ParkIntroduceSubmitVO vo){
        parkIntroduceService.createParkIntroduce(vo);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("根据id删除park_introduce")
    @DeleteMapping("/deleteParkIntroduce")
    public ResponseEntity<ResultObject> deleteParkIntroduce(@RequestParam(value = "id",required = true) int id){
        parkIntroduceService.deleteParkIntroduce(id);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation(value = "更新park_introduce", notes = "parkIntroduce：封装对象，其中id必传, 介绍内容选填。" +
            "contacts:对象集合，contactPerson联系人，contactPhone联系方式。")
    @PostMapping("/updateParkIntroduce")
    public ResponseEntity<ResultObject> updateParkIntroduce(@RequestBody ParkIntroduceSubmitVO vo){
        parkIntroduceService.updateParkIntroduce(vo);
        return new ResponseEntity<>(new ResultObject<>(), HttpStatus.OK);
    }

    @ApiOperation("根据id查询park_introduce")
    @GetMapping("/findParkIntroduceById")
    public ResponseEntity<ResultObject<ParkIntroduce>> findParkIntroduceById(@RequestParam(value = "id",required = true) int id){
        return new ResponseEntity<>(new ResultObject(parkIntroduceService.findParkIntroduceById(id)),HttpStatus.OK);
    }

    @ApiOperation("根据园区id查询park_introduce")
    @GetMapping("/findDetailByParkId")
    public ResponseEntity<ResultObject<ParkIntroduce>> findDetailByParkId(@RequestParam(value = "parkId",required = true) long parkId){
        JSONObject jsonObject = parkIntroduceService.findDetailByParkId(parkId);
        ResultObject res = new ResultObject(jsonObject);
        return new ResponseEntity<>(res, HttpStatus.OK);
    }

}